home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-01-28 | 65.3 KB | 2,690 lines |
- Wednesday 28-Jan-98 10:45:38
-
- Copyright:
-
- Fictive Map Maker is Copyright © 1997-1998 Valentin Asler / Fictive Reality.
- All rights reserved.
-
- This software may not be sold for any profit or included on any CD Rom
- titles, magazines or any other commercial means of distribution without the
- agreement of the author.
-
- --
-
- Introduction:
-
- Fictive Map Maker is a tool with a main use to build 3D scenes and is
- especially adapted for games, since it came out of a 3D game project.
- Since I didn't find any 3D map/scene editors which would contain everything
- needed, for development of a game I started working on, I had to write one
- myself. It can load Lightwave objects.
- This project was started in summer of 1997.
-
- At least MC68030/50MHz recommended for larger scenes.
- The FPU version will work much faster, cause of heavy use of floating points.
-
- --
-
- Contact:
-
- Contact me via e-mail at: Valentin.Asler@public.srce.hr
-
- snail mail: Valentin Asler
- Drage Gervaisa 34
- 10000 Zagreb, Croatia
-
- You can find me also on irc, AmigaNET and IrcNET.
- AmigaNET, channel: #Amiga.
- IrcNET, channels: #AmyCoders and #AmigaScne.
- Nick: Slash^FVR mostly, sometimes Smece and sometimes just plain Slash.
-
- Newest updated version you can download from: http://public.srce.hr/~vasler
-
- If you encounter any bugs, please send me bug reports via e-mail.
-
- --
-
- Greetz and thanx:
-
- Thanks goes out to people who helped me with this, especially Newlook,
- thanx m8.
-
- Hiya #Amiga, #AmigaScne, #AmyCoders and everybody I know.
-
- --
-
- Licence:
-
- Fictive Map Maker is a shareware and users are encouraged to register it.
- For further information read the file named REGISTER.
-
- This tool may be passed on as long as ALL files are included and NONE of
- them are changed and no fee is asked for it except the price of media.
-
- If you want me to continue the development of this tool, please register.
- People who really don't have money may use this tool freely.
-
- Registered or not, please send me an e-mail so I know somebody uses it.
-
- Thank you for using Fictive Map Maker.
-
- --
-
- Disclaimer:
-
- This software is provided "AS IS" and the author disclaims ALL warranties,
- express or implied, including, but not limited to, the implied warranties
- of merchantability and fitness for a particular purpose.
- The author will not be held liable for any damages caused by use or misuse
- of this software.
- The author is not in any way required, nor bound to continue development of
- this software, nor to correct any encountered bugs.
-
- The user of this program uses it at his or her own risk.
-
- --
-
- Requirements:
-
- At least ROM 3.0, 020. (ROM 2.04 maybe, but I'm not sure, try it).
-
- --
-
- Things to do:
-
- Make save-file version which can be easily loaded into 3D engines.
- Optimise.
- Enhance and finish some options.
- Enhance 3D editor.
- Enhance 3D view.
-
- --
-
- Explanation of features:
-
- Fictive Map Maker has a 3D editor which is used to construct 3D scenes out
- of polygons, objects and fields.
- Polygons consist out of 2 main groups: With 3 points and with 4 points.
- Objects consist out of polygons and can be connected/"stuck" to main maps and
- to fields.
- Fields consists out of polygons and objects and can too be "stuck" to main
- maps.
- Polygons and map fields can have attributes and polygons can have textures.
- More than one actions can be joined to objects and points in 3D space.
- Monsters can be added to the map.
- Maps for now have size from -2 billion to about 2 billion (32bit signed).
- Loads Lightwave objects. Explanation how to load them can be found together
- with explanation for "Load" gadget.
-
- --
-
- Explanation of gadgets and editor:
-
- The biggest part of the screen is used by 4 areas bordered with black
- lines. Left-Down one is a front view. Left-Up is a top view. Right-Down is
- a side view. Right-Up is a 3D view. Later to be implemented will be one
- huge view which will to users choice display any of those views enlarged.
- Small views are 200x200 points and large view will be 400x400 points.
- For now user can edit scene in front, top and side views and later 3D.
-
- The leftmost display gadgets with X, Y and Z left of them show where on the
- editor views mouse is pointing. They are not changed only according to
- mouse position, but also to view alignment, zoom factor and view depth.
-
- VD gadget is a View Depth input gadget. View Depth tells the display
- function how "deep" in front, top and side views it should display, ie. if
- a polygon is situated farther than View Depth edge it gets 3D cut.
-
- Grid tells the edit function in how large steps it should change
- coordinates when scene is being edited with using mouse.
-
- MZV is a Move, Zoom Value and it says in how large steps Map Align and/or
- Zoom Factor should be changed when using "Move" and "Zoom" button gadgets.
-
- P is a value which tells the mouse button read function how precise the
- user wants the "point grab" function to be, ie. if the user sets it small,
- he will have to pick the points very precisely and if he sets it large, he
- won't have to be so precise, but in that case he may accidently choose a
- wrong point to grab.
-
- ZF is a Zoom Factor input gadget and it sets the size of edit/display
- windows to needed one.
-
- MA X, Y, Z are the Map Align gadgets.
-
- Load and LoadA gadgets are gadgets used when loading, still not fully
- finished, so are doing the same operation.
- Load gadgets atempt to load a selected object, lets say Poly3 (First Cycle
- gadget), from the file you choose. The file you choose must have the same
- object as on first cycle gadget. The active item will be overwriten.
-
- NOTE: For loading Lightwave objects, you must enter Object editor and
- choose "Object" list (first cycle).
-
- Save and SaveA gadgets are gadgets used when saving, still not fully
- finished, so are doing the same operation.
- For now it saves the object you choose, and from active item, to the last
- one.
-
- Suggested sufixes: .fvm, .fvp3, .fvp4, .fvf, .fvo, .fvmn, .fvmf, .fvmo,
- .fvmm, .fvt, .fva, .fvfd, .fvma
-
- NOTE: If you find some error in Save and Load functions, please e-mail me.
-
- Full, Front, Top, Side MX_KIND gadget is used to set the size of the window
- and to set the wanted view. *Not implemented*
-
- Editor, M Editor, F editor and O editor MX_KIND gadget is used to set the
- editor under which the work is about to be done, explained later.
-
- First cycle gadget is used to set the item the operations will be
- implemented on. It equals to the lowest MX_KIND gadget. Items expl. later.
-
- Buttons left and right of first cycle gadget are used to move along the
- list of added items.
-
- Two buttons most right of first cycle gadget are used to change the
- position of the attribute that is being changed on a chosen item, ie. the
- item has 12 attributes and only 8 fit in two columns of input gadgets.
-
- N input gadgets. The left most one is used as a number of active item
- member and the right one is used for names.
-
- Under them, right of X, Y, Z, input gadgets are used to set the values of
- some items.
- Note that items don't have either same number, either same function of their
- attributes.
-
- Add gadget is used to add another member of specified item.
-
- Delete gadget is used to delete member of specified item.
-
- Copy and Paste gadgets are used to copy and paste gadget values. *N/A*
-
- Zoom In and Zoom Out gadgets are used to change the Zoom factor value.
-
- Up-Down, Left-Right, Forth-Back button gadgets are used to change map
- alignment.
-
- Second cycle gadget is used to set specific values of some items, ie. set
- Map Object to point to a selected Object item.
-
- Input gadgets under it state the number and name of member in item list,
- ie. Object number and its name.
-
- Buttons left and right of second cycle gadget are used to move through the
- list of available items.
-
- Clear Scene is used to clear the whole scene and all items, not working yet.
-
- 3D View checkbox is checked if you want the 3D view to display.
-
- Grid checkbox is checked if you want the grid to display.
-
- ARed checkbox is an "Auto Redraw" option which is checked when you want the
- view to redraw after you press any gadget concerning the view.
-
- Zoom and UnZo gadgets are used for graphical zoom. Usage: Press Zoom, use
- mouse and left mouse button to surround an area and release the left mouse
- button. After that the Zoom Factor and Align[X,Y,Z] changes to the area you
- have chosen. Press UnZo to return Zoom Factor and Alignment to the contents
- before using the Zoom gadget.
-
- Align and UnAl gadgets are used to graphically set the Alignment of the
- view. Usage: Press Align, press left mouse button in one of 3 views (except
- 3D view). Alignment is not set to the point you chose. Pressing UnZo
- button returns the values to previous state.
-
- PP, PPP and PPN gadgets are used for picking a polygon to be active. Press
- PP and then press on the poly you want to be active, on the display, in
- Front, Top and Side views. PPN and PPP are used to pick next and previous
- polygons with matching position, and they can be of use when 2 or more
- polygons overlap.
-
- NOTE: Orange coloured polygons are the ones you chose in the list and have
- the priority over other polygons, when moving their points with the mouse.
- Poly3s have higher priorities than Poly4s.
- SAVE before loading LW objects, cause it dies on some.
- It can load only polygons with 3 and 4 points from LWOB file.
-
- --
-
- First cycle gadget Item explanation:
-
- The items will be displayed as their values are input with input gadgets
- together with second cycle gadget and common attributes.
-
- Map:
-
- ________________
- | Map |
- |________________|
- _________________
- N | Number | Name |
- |________|________|
- X | X | X |
- |________|________|
- Y | Y | Y |
- |________|________|
- Z | Z | Z |
- |________|________|
-
- Number value displays number of active Map.
- Name is a name of the active Map.
- X, Y and Z are coordinates of the Map.
- NOTE: Maps can only be changed in Map Editor.
-
- Poly3:
- ________________
- | Poly3 |
- |________________|
- _________________
- N | Number | Name |
- |________|________|________
- X | X1 | X2 | X3 |
- |________|________|________|
- Y | Y1 | Y2 | Y3 |
- |________|________|________|
- Z | Z1 | Z2 | Z3 |
- |________|________|________|
-
- ________________ ________________
- | Texture | | Attribute |
- |________________| |________________|
-
- Number value displays number of active Poly3.
- Name is not used in case of Poly3.
- X1, Y1, Z1 are the coordinates of 1. point, X2, Y2, Z2 of 2. and X3, Y3 and
- Z3 od 3.
- Since we can join a texture and an attribute to the Poly3, for that we use
- second cycle gadget. By choosing a Texture or Attribte on it and by sliding
- through the list of available Texture or Attribute members, we choose the
- texture or attribute that Poly3 should have.
- NOTE: If we want to set Attribute and Texture, we have to Add them first.
- Otherwise Poly3 does not point to any Texture or/and Attribute.
-
- Poly4:
- ________________
- | Poly4 |
- |________________|
- _________________
- N | Number | Name |
- |________|________|________ ________
- X | X1 | X2 | X3 | X4 |
- |________|________|________|________|
- Y | Y1 | Y2 | Y3 | Y4 |
- |________|________|________|________|
- Z | Z1 | Z2 | Z3 | Z4 |
- |________|________|________|________|
-
- ________________ ________________
- | Texture | | Attribute |
- |________________| |________________|
-
- Poly4 is almost identical to Poly3, except it has 4 points in 3D space.
-
- Field:
- ________________
- | Field |
- |________________|
- _________________
- N | Number | Name |
- |________|________|
- X | | |
- |________|________|
- Y | | |
- |________|________|
- Z | | |
- |________|________|
-
- Number value displays number of active Field.
- Name is a name of the active Field.
- NOTE: Fields can only be changed in Field Editor.
-
- Object:
- ________________
- | Object |
- |________________|
- _________________
- N | Number | Name |
- |________|________|
- X | | |
- |________|________|
- Y | | |
- |________|________|
- Z | | |
- |________|________|
-
- Number value displays number of active Object.
- Name is a name of the active Object.
- NOTE: Fields can only be changed in Object Editor.
-
- Monster:
- ________________
- | Monster |
- |________________|
- _________________
- N | Number | Name |
- |________|________|
- X | | |
- |________|________|
- Y | | |
- |________|________|
- Z | | |
- |________|________|
-
- Number value displays number of active Monster.
- Name is a name of the active Monster.
-
- Map Field:
-
- ________________
- | Map Field |
- |________________|
- _________________
- N | Number | Name |
- |________|________|
- X | X | X |
- |________|________|
- Y | Y | Y |
- |________|________|
- Z | Z | Z |
- |________|________|
- ________________
- | Field List |
- |________________|
-
- Number value displays number of active Map Field.
- Name is a name of the active Monster.
- Name is not used in case of Poly3.
- X, Y and Z are the coordinates of the Map Field in the Map.
- Map Field is really a pointer used to connect Fields (explained before) to
- Maps. We set the coordinates of a Map Field (but really the coordinates of
- a real Field on the Map) using input gadgets and we set to which Field the
- Map Field is pointing using second cycle gadget.
- NOTE: If we want to set to which Field the Map Field us pointing, we have to
- Add at least one Field. Otherwise Map Field does not pointto any Field.
- Map Fields can be changed only in Map Editor.
-
- Map Object:
- ________________
- | Map Object |
- |________________|
- _________________
- N | Number | Name |
- |________|________|
- X | X | X |
- |________|________|
- Y | Y | Y |
- |________|________|
- Z | Z | Z |
- |________|________|
- ________________
- | Object List |
- |________________|
-
- Map Object is very similar to Map Field, except it can be used in Map
- Editor and in Field Editor.
- NOTE: Map Objects in Map Editor and in Field Editor are not the same, those
- are two separated groups, used for same purpose.
-
- Map Monster:
- ________________
- | Map Monster |
- |________________|
- _________________
- N | Number | Name |
- |________|________|
- X | X | X |
- |________|________|
- Y | Y | Y |
- |________|________|
- Z | Z | Z |
- |________|________|
- ________________
- | Monster List |
- |________________|
-
- Map Monster is very similar to Map Field and Map Object, except it can be
- used in Map Editor only.
-
- Text List:
-
- ________________
- | Text List |
- |________________|
- _________________
- N | Number | Name |
- |________|________|
- X | | |
- |________|________|
- Y | | |
- |________|________|
- Z | | |
- |________|________|
-
- Number value displays number of active member in Text (texture) List.
- Name is a name of the active member in Text List.
-
- This gadget is used for adding another membet in Text (texture) List. It is
- saved with its name and user has to adapt his program to load the right
- texture picture.
-
- Attrib List:
-
- ________________
- | Attrib List |
- |________________|
- _________________
- N | Number | Name |
- |________|________|________
- X | A1 | A4 | A7 |
- |________|________|________|
- Y | A2 | A5 | A8 |
- |________|________|________|
- Z | A3 | A6 | A9 |
- |________|________|________|
-
- Number value displays number of active member in Attrib (attribute) List.
- Name is a name of the active member in Attrib List.
- A1 to A9 are are 9 unsigned int values to be entered as attribute values.
- The user adapts his program to use these values.
-
- Field Descr:
- ________________
- | Field Descr |
- |________________|
- _________________
- N | Number | Name |
- |________|________|________ ________
- X | X | A1 | A4 | A7 |
- |________|________|________|________|
- Y | Y | A2 | A5 | A8 |
- |________|________|________|________|
- Z | Z | A3 | A6 | A9 |
- |________|________|________|________|
-
- Number value displays number of active member in Field Descr (description).
- Name is a name of the active member in Field Descr list.
- X, Y and Z are the coordinates of field the user wants to define (long).
- A1 to A9 are 9 unsigned int values.
- Example: Just as you can add attributes to polygons, you can add attributes
- to chosen point in space with this option.
- NOTE: Field Descr can only be used in Map Editor.
-
- Set Actions:
- ________________
- | Set Actions |
- |________________|
- _________________
- N | Number | |
- |________|________|
- X | X | A1 |
- |________|________|
- Y | Y | A2 |
- |________|________|
- Z | Z | |
- |________|________|
-
- ________________ ________________
- | Obj Source L | | Obj Destin L |
- |________________| |________________|
-
- Number value displays number of active member in Set Actions list.
- X, Y and Z are coordinates for action trigger in 3D space.
- A1 and A2 are Action Values. (unsigned long)
- Obj Source L and Obj Destin L are pointers to Map Objects. Obj Source L
- points to trigger Map Object and Obj Source L points to action Map Object,
- ie. the Map Object to which something happens. A1 and A2 are values which
- the users program interprets and based upon them comes to a decision what
- should happen to a action/destination Map Object. If user wants something
- to happen if, lets say, player comes to a specified position in 3D space,
- X, Y and Z coordinates are used.
- For my 3D game engine I needed that kind of setup, but after all user can
- use these values any way he wants to and intepret them in his program.
- NOTE: Set Actions can be used only in Map Editor.
- User can point to an Map Object with as many actions as he wants.
-
- That just about covers all current gadgets.
- If something is not clear to you, contact me via e-mail and I'll try to
- answer your question and correct the doc so it explains the subject better.
- If you think something is missing in the tool, or is not expanded enough,
- contact me via e-mail and I'll think about adding/correcting when I find
- the time to do it.
-
- --
-
- Save and Load:
-
- This part is for you programmers who want to use this tool and are
- interested how it saves and loads the data. To make it easyer for you and
- me to get past this part I'll assume you have the knowlege of C and I'll
- insert C source for saving and loading here and explain it. Although I'll
- give some explanations, I hope you can read C and out of it get the idea
- how the save file looks. If there will be anything uncelar to you, please
- e-mail me and I'll try to explain it.
-
- Protos and structures:
-
- struct Poly3 { long int x1,y1,z1;
- long int x2,y2,z2;
- long int x3,y3,z3;
- struct Text *Texture;
- struct Attrib *Attribute;
- struct Poly3 *PolyPrevious3;
- struct Poly3 *PolyNext3;
- };
-
- struct Poly4 { long int x1,y1,z1;
- long int x2,y2,z2;
- long int x3,y3,z3;
- long int x4,y4,z4;
- struct Text *Texture;
- struct Attrib *Attribute;
- struct Poly4 *PolyPrevious4;
- struct Poly4 *PolyNext4;
- };
-
- struct Action { long int x,y,z;
- struct MapObject *SourceObject;
- struct MapObject *DestObject;
- unsigned long int ActionValue;
- unsigned long int ActionValue1;
- struct Action *ActionPrevious;
- struct Action *ActionNext;
- };
-
- struct Object { unsigned long int Object;
- unsigned long int Used;
- struct Poly3 *Poly3;
- struct Poly3 *PolyActive3;
- struct Poly3 *PolyLast3;
- unsigned long int ActivePoly3Nr;
- struct Poly4 *Poly4;
- struct Poly4 *PolyActive4;
- struct Poly4 *PolyLast4;
- unsigned long int ActivePoly4Nr;
- char name[25];
- struct Object *NObject;
- struct Object *PObject;
- };
-
- struct MapObject { unsigned long int Used;
- unsigned long int MapObject;
- long int x,y,z;
- struct Object *Object;
- struct MapObject *PMapObject;
- struct MapObject *NMapObject;
- };
-
- struct MapField { long int x,y,z;
- struct Field *Field;
- struct MapField *PMapField;
- struct MapField *NMapField;
- };
-
- struct Field { unsigned long int Field;
- unsigned long int Used;
- struct Poly3 *Poly3;
- struct Poly3 *PolyActive3;
- struct Poly3 *PolyLast3;
- unsigned long int ActivePoly3Nr;
- struct Poly4 *Poly4;
- struct Poly4 *PolyActive4;
- struct Poly4 *PolyLast4;
- unsigned long int ActivePoly4Nr;
- struct MapObject *MapObject;
- struct MapObject *MapObjectActive;
- struct MapObject *MapObjectLast;
- unsigned long int ActiveMapObjectNr;
- char name[25];
- struct Field *NField;
- struct Field *PField;
- };
-
- struct Monster { unsigned long int Monster;
- unsigned long int Used;
- char name[25];
- struct Monster *NMonster;
- struct Monster *PMonster;
- };
-
- struct MapMonster { long int x,y,z;
- struct Monster *Monster;
- struct MapMonster *PMapMonster;
- struct MapMonster *NMapMonster;
- };
-
- struct Map { long int x,y,z;
- struct Poly3 *Poly3;
- struct Poly3 *PolyActive3;
- struct Poly3 *PolyLast3;
- unsigned long int ActivePoly3Nr;
- struct Poly4 *Poly4;
- struct Poly4 *PolyActive4;
- struct Poly4 *PolyLast4;
- unsigned long int ActivePoly4Nr;
- struct Action *Action;
- struct Action *ActionActive;
- struct Action *ActionLast;
- unsigned long int ActiveActionNr;
- struct MapField *MapField;
- struct MapField *MapFieldActive;
- struct MapField *MapFieldLast;
- unsigned long int ActiveMapFieldNr;
- struct MapObject *MapObject;
- struct MapObject *MapObjectActive;
- struct MapObject *MapObjectLast;
- unsigned long int ActiveMapObjectNr;
- struct MapMonster *MapMonster;
- struct MapMonster *MapMonsterActive;
- struct MapMonster *MapMonsterLast;
- unsigned long int ActiveMapMonsterNr;
- struct FieldDes *FieldDes;
- struct FieldDes *FieldDesActive;
- struct FieldDes *FieldDesLast;
- unsigned long int ActiveFieldDesNr;
- char name[25];
- struct Map *NMap;
- struct Map *PMap;
- };
-
- struct Text { unsigned long int Texture;
- unsigned long int Used;
- char name[25];
- struct Text *NText;
- struct Text *PText;
- };
-
- struct Attrib { unsigned long int Attribute;
- unsigned long int Used;
- unsigned int r, g, b;
- unsigned int Illumination;
- unsigned int Transparency;
- unsigned int Reflectivity;
- unsigned int Smoothyness;
- unsigned int Bumpyness;
- unsigned int Effect;
- char name[25];
- struct Attrib *NAttrib;
- struct Attrib *PAttrib;
- };
-
- struct FieldDes { unsigned long int Field;
- long int x,y,z;
- unsigned int A,B,C;
- unsigned int D,E,F;
- unsigned int G,H,I;
- char name[25];
- struct FieldDes *NFD;
- struct FieldDes *PFD;
- };
-
- struct Map Scene = { 0, 0, 0, NULL, NULL, NULL, 0, NULL, NULL, NULL, 0,
- NULL, NULL, NULL, 0, NULL, NULL, NULL, 0,
- NULL, NULL, NULL, 0, NULL, NULL, NULL, 0,
- NULL, NULL, NULL, 0,
- "", NULL, NULL };
-
- struct Field Field = { 0, 0, NULL, NULL, NULL, 0, NULL, NULL, NULL, 0, NULL,
- NULL, NULL, 0, "",NULL, NULL };
-
- struct Object Object_ = { 0, 0, NULL, NULL, NULL, 0, NULL, NULL, NULL, 0, "",
- NULL, NULL };
-
- struct Monster Monster = { 0, 0, "", NULL, NULL };
-
- struct Text Texture = { 0, 0, "", NULL, NULL };
-
- struct Attrib Attribute = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", NULL, NULL};
-
- struct Map *ActiveMap;
- struct Map *LastMap;
- struct Field *ActiveField;
- struct Field *LastField;
- struct Object *ActiveObject;
- struct Object *LastObject;
- struct Monster *ActiveMonster;
- struct Monster *LastMonster;
- struct Text *ActiveText;
- struct Text *LastText;
- struct Attrib *ActiveAttrib;
- struct Attrib *LastAttrib;
-
- UWORD LastMapNr;
- UWORD ActiveMapNr;
- UWORD LastFieldNr;
- UWORD ActiveFieldNr;
- UWORD LastObjectNr;
- UWORD ActiveObjectNr;
- UWORD LastMonsterNr;
- UWORD ActiveMonsterNr;
- UWORD LastTextNr;
- UWORD ActiveTextNr;
- UWORD LastAttribNr;
- UWORD ActiveAttribNr;
-
- void SavePoly3(struct Poly3 *Poly3First, struct Poly3 *Poly3Last, FILE *fp);
- void SavePoly4(struct Poly4 *Poly4First, struct Poly4 *Poly4Last, FILE *fp);
- void SaveAction(struct Action *ActionFirst,struct Action *ActionLast,FILE *fp);
- void SaveObject(struct Object *ObjectFirst,struct Object *ObjectLast,FILE *fp);
- void SaveMapObject( struct MapObject *MOF, struct MapObject *MOL, FILE *fp);
- void SaveMapField( struct MapField *MFF, struct MapField *MFL, FILE *fp);
- void SaveField(struct Field *FieldFirst,struct Field *FieldLast,FILE *fp);
- void SaveMonster(struct Monster *MonsterFirst,struct Monster *MonsterLast,FILE *fp);
- void SaveMapMonster(struct MapMonster *MMF,struct MapMonster *MML,FILE *fp);
- void SaveMap(struct Map *MapFirst,struct Map *MapLast,FILE *fp);
- void SaveText(struct Text *TextFirst,struct Text *TextLast,FILE *fp);
- void SaveAttrib(struct Attrib *AttribFirst,struct Attrib *AttribLast,FILE *fp);
- void SaveFieldDes( struct FieldDes *FDF, struct FieldDes *FDL ,FILE *fp );
-
- struct Map * LoadMap(struct Map *, unsigned long int, FILE *);
- struct Poly3 *LoadPoly3(struct Poly3 *, unsigned long, FILE *);
- struct Poly4 *LoadPoly4(struct Poly4 *, unsigned long, FILE *);
- struct Action *LoadAction(struct Action *, unsigned long, struct MapObject *, FILE *);
- struct Object *LoadObject(struct Object *, unsigned long, FILE *);
- struct MapObject *LoadMapObject(struct MapObject *, unsigned long, FILE *);
- struct MapField *LoadMapField(struct MapField *, unsigned long, FILE *);
- struct Field *LoadField(struct Field *, unsigned long, FILE *);
- struct Monster *LoadMonster(struct Monster *, unsigned long, FILE *);
- struct MapMonster *LoadMapMonster(struct MapMonster *, unsigned long, FILE *);
- struct Text *LoadText(struct Text *, unsigned long, FILE *);
- struct Attrib *LoadAttrib(struct Attrib *, unsigned long, FILE *);
- struct FieldDes *LoadFieldDes(struct FieldDes *, unsigned long, FILE *);
-
- Save functions:
-
- To understand the save and load functions just follow the functions.
- Start with "void Save( void ) {" and "void Load( void ) {". Some parts are
- very similar in some functions ( you will recognize 2 main types of
- functions, they all work acording to 2 principles, function that represents
- group 1 is Save/Load Map function and group 2 is Save/Load Poly3 function )
- and that should ease your understanding of those functions. For easyer
- understanding try saving the "not touched" Map, totally clear Map, and try
- to connect it to the functions.
- Soon will write a save function for making much less complex save files,
- ready to easy load into 3D engines.
-
- NOTE: For now you can save only all of the data and load it the same way.
- I will extend that very soon, so you will be able to save and load
- what you need.
-
-
-
- void Save( void ) {
-
- struct Library *AslBase;
-
- struct FileRequester *fr;
-
- FILE *fp;
-
- char Smece[] = "Slash^FVR FVMap";
- char File[400];
- char Dir[400];
- char DirFile[400];
-
- if (AslBase = OpenLibrary("asl.library", 36L))
- {
- if (fr = (struct FileRequester *)
- AllocAslRequest(ASL_FileRequest, frtags ))
- {
- if (AslRequest(fr, 0L)) {
- sprintf( Dir, "%s%s", fr->rf_Dir );
- sprintf( File, "%s%s", fr->rf_File );
- sprintf( DirFile, "%s%s", fr->rf_Dir, fr->rf_File);
- }
- else {
- return;
- }
- }
- FreeAslRequest(fr);
- }
- CloseLibrary(AslBase);
-
- if( strlen( File ) == 0 )
- return;
-
- fp = fopen( DirFile, "wb" );
- if( fp == NULL )
- return;
-
- fwrite( Smece, 16, 1, fp );
-
- SaveMap( &Scene, LastMap, fp );
-
- fclose(fp);
-
- }
-
- /* START OF SAVE FUNCTIONS */
-
- void SavePoly3(struct Poly3 *Poly3First, struct Poly3 *Poly3Last, FILE *fp) {
-
- long int la[11];
- unsigned long int Poly3C = 0;
- struct Poly3 *Poly3P = Poly3First;
-
- if( Poly3Last != NULL ) {
-
- while( Poly3P != Poly3Last->PolyNext3 ) {
- Poly3C++;
- Poly3P = Poly3P->PolyNext3;
- }
- la[0] = 1; /* A description number 0 Map, 1 Poly3, .... */
- la[1] = Poly3C; /* Number of members to save/load. */
- fwrite(la, 2, 4, fp);
- }
-
- while( Poly3First != Poly3Last->PolyNext3 && Poly3First != NULL ) {
-
- la[0] = Poly3First->x1; /* Data, who'd guess :) */
- la[1] = Poly3First->y1;
- la[2] = Poly3First->z1;
- la[3] = Poly3First->x2;
- la[4] = Poly3First->y2;
- la[5] = Poly3First->z2;
- la[6] = Poly3First->x3;
- la[7] = Poly3First->y3;
- la[8] = Poly3First->z3;
- la[9] = Poly3First->Texture->Texture;
- la[10] = Poly3First->Attribute->Attribute;
- fwrite(la, 11, 4, fp);
-
- Poly3First = Poly3First->PolyNext3;
- }
-
- }
-
- void SavePoly4(struct Poly4 *Poly4First, struct Poly4 *Poly4Last, FILE *fp) {
-
- long int la[14];
- unsigned long int Poly4C = 0;
- struct Poly4 *Poly4P = Poly4First;
-
- if( Poly4Last != NULL ) {
-
- while( Poly4P != Poly4Last->PolyNext4 ) {
- Poly4C++;
- Poly4P = Poly4P->PolyNext4;
- }
- la[0] = 2;
- la[1] = Poly4C;
- fwrite(la, 2, 4, fp);
- }
-
- while( Poly4First != Poly4Last->PolyNext4 && Poly4First != NULL ) {
-
- la[0] = Poly4First->x1;
- la[1] = Poly4First->y1;
- la[2] = Poly4First->z1;
- la[3] = Poly4First->x2;
- la[4] = Poly4First->y2;
- la[5] = Poly4First->z2;
- la[6] = Poly4First->x3;
- la[7] = Poly4First->y3;
- la[8] = Poly4First->z3;
- la[9] = Poly4First->x4;
- la[10] = Poly4First->y4;
- la[11] = Poly4First->z4;
- la[12] = Poly4First->Texture->Texture;
- la[13] = Poly4First->Attribute->Attribute;
- fwrite(la, 14, 4, fp);
-
- Poly4First = Poly4First->PolyNext4;
- }
-
- }
-
- void SaveAction(struct Action *ActionFirst,struct Action *ActionLast,FILE *fp) {
-
- long la[7];
- unsigned long int ActionC = 0;
- struct Action *ActionP = ActionFirst;
-
- if( ActionLast != NULL ) {
-
- while( ActionP != ActionLast->ActionNext ) {
- ActionC++;
- ActionP = ActionP->ActionNext;
- }
- la[0] = 12;
- la[1] = ActionC;
- fwrite(la, 2, 4, fp);
- }
-
- while( ActionFirst != ActionLast->ActionNext && ActionFirst != NULL ) {
-
- la[0] = ActionFirst->x;
- la[1] = ActionFirst->y;
- la[2] = ActionFirst->z;
- if( ActionFirst->SourceObject != NULL )
- la[3] = ActionFirst->SourceObject->MapObject;
- else
- la[3] = 0;
- la[4] = ActionFirst->DestObject->MapObject;
- if( ActionFirst->DestObject != NULL )
- la[4] = ActionFirst->DestObject->MapObject;
- else
- la[4] = 0;
- la[5] = ActionFirst->ActionValue;
- la[6] = ActionFirst->ActionValue1;
- fwrite(la, 7, 4, fp);
-
- ActionFirst = ActionFirst->ActionNext;
- }
-
- }
-
- void SaveObject(struct Object *ObjectFirst,struct Object *ObjectLast,FILE *fp) {
-
- long la[3];
-
- unsigned long int ObjectC = 0;
- struct Object *ObjectP = ObjectFirst;
-
- if( ObjectLast != NULL ) {
-
- while( ObjectP != ObjectLast->NObject ) {
- ObjectC++;
- ObjectP = ObjectP->NObject;
- }
- la[0] = 4;
- la[1] = ObjectC;
- fwrite(la, 2, 4, fp);
- }
-
- while( ObjectFirst != ObjectLast->NObject && ObjectFirst != NULL ) {
-
- fwrite(ObjectFirst->name, 26, 1, fp);
-
- if( ObjectFirst->Poly3 != NULL )
- SavePoly3( ObjectFirst->Poly3, ObjectFirst->PolyLast3, fp);
- else {
- la[0] = 1;
- la[1] = 0;
- fwrite(la, 2, 4, fp);
- }
- if( ObjectFirst->Poly4 != NULL )
- SavePoly4( ObjectFirst->Poly4, ObjectFirst->PolyLast4, fp);
- else {
- la[0] = 2;
- la[1] = 0;
- fwrite(la, 2, 4, fp);
- }
-
- ObjectFirst = ObjectFirst->NObject;
- }
-
- }
-
- void SaveMapObject( struct MapObject *MOF, struct MapObject *MOL, FILE *fp) {
-
- unsigned long int la[4];
-
- unsigned long int MapObjectC = 0;
- struct MapObject *MapObjectP = MOF;
-
- if( MOL != NULL ) {
-
- while( MapObjectP != MOL->NMapObject ) {
- MapObjectC++;
- MapObjectP = MapObjectP->NMapObject;
- }
- la[0] = 7;
- la[1] = MapObjectC;
- fwrite(la, 2, 4, fp);
- }
-
- while( MOF != MOL->NMapObject && MOF != NULL ) {
-
- la[0] = MOF->x;
- la[1] = MOF->y;
- la[2] = MOF->z;
- la[3] = MOF->Object->Object;
- fwrite(la, 4, 4, fp);
-
- MOF = MOF->NMapObject;
- }
-
- }
-
- void SaveMapField( struct MapField *MFF, struct MapField *MFL, FILE *fp) {
-
- unsigned long int la[4];
-
- unsigned long int MapFieldC = 0;
- struct MapField *MapFieldP = MFF;
-
- if( MFL != NULL ) {
-
- while( MapFieldP != MFL->NMapField ) {
- MapFieldC++;
- MapFieldP = MapFieldP->NMapField;
- }
- la[0] = 6;
- la[1] = MapFieldC;
- fwrite(la, 2, 4, fp);
- }
-
- while( MFF != MFL->NMapField && MFF != NULL ) {
-
- la[0] = MFF->x;
- la[1] = MFF->y;
- la[2] = MFF->z;
- la[3] = MFF->Field->Field;
- fwrite(la, 4, 4, fp);
-
- MFF = MFF->NMapField;
- }
-
- }
-
- void SaveField(struct Field *FieldFirst,struct Field *FieldLast,FILE *fp) {
-
- long la[3];
-
- unsigned long int FieldC = 0;
- struct Field *FieldP = FieldFirst;
-
- if( FieldLast != NULL ) {
-
- while( FieldP != FieldLast->NField ) {
- FieldC++;
- FieldP = FieldP->NField;
- }
- la[0] = 3;
- la[1] = FieldC;
- fwrite(la, 2, 4, fp);
- }
-
- while( FieldFirst != FieldLast->NField && FieldFirst != NULL ) {
-
- fwrite(FieldFirst->name, 26, 1, fp);
-
- if( FieldFirst->Poly3 != NULL )
- SavePoly3( FieldFirst->Poly3, FieldFirst->PolyLast3, fp);
- else {
- la[0] = 1;
- la[1] = 0;
- fwrite(la, 2, 4, fp);
- }
- if( FieldFirst->Poly4 != NULL )
- SavePoly4( FieldFirst->Poly4, FieldFirst->PolyLast4, fp);
- else {
- la[0] = 2;
- la[1] = 0;
- fwrite(la, 2, 4, fp);
- }
- if( FieldFirst->MapObject != NULL )
- SaveMapObject( FieldFirst->MapObject, FieldFirst->MapObjectLast, fp);
- else {
- la[0] = 7;
- la[1] = 0;
- fwrite(la, 2, 4, fp);
- }
-
- FieldFirst = FieldFirst->NField;
- }
-
- }
-
- void SaveMonster(struct Monster *MonsterFirst,struct Monster *MonsterLast,FILE *fp) {
-
- long la[3];
-
- unsigned long int MonsterC = 0;
- struct Monster *MonsterP = MonsterFirst;
-
- if( MonsterLast != NULL ) {
-
- while( MonsterP != MonsterLast->NMonster ) {
- MonsterC++;
- MonsterP = MonsterP->NMonster;
- }
- la[0] = 5;
- la[1] = MonsterC;
- fwrite(la, 2, 4, fp);
- }
-
- while( MonsterFirst != MonsterLast->NMonster && MonsterFirst != NULL ) {
-
- fwrite(MonsterFirst->name, 26, 1, fp);
-
- MonsterFirst = MonsterFirst->NMonster;
- }
-
- }
-
- void SaveMapMonster(struct MapMonster *MMF,struct MapMonster *MML,FILE *fp) {
-
- unsigned long int la[4];
-
- unsigned long int MapMonsterC = 0;
- struct MapMonster *MapMonsterP = MMF;
-
- if( MML != NULL ) {
-
- while( MapMonsterP != MML->NMapMonster ) {
- MapMonsterC++;
- MapMonsterP = MapMonsterP->NMapMonster;
- }
- la[0] = 8;
- la[1] = MapMonsterC;
- fwrite(la, 2, 4, fp);
- }
-
- while( MMF != MML->NMapMonster && MMF != NULL ) {
-
- la[0] = MMF->x;
- la[1] = MMF->y;
- la[2] = MMF->z;
- la[3] = MMF->Monster->Monster;
- fwrite(la, 4, 4, fp);
-
- MMF = MMF->NMapMonster;
- }
-
- }
-
- void SaveMap(struct Map *MapFirst,struct Map *MapLast,FILE *fp) {
-
- long la[3];
-
- unsigned long int MapC = 0;
- struct Map *MapP = MapFirst;
-
- if( MapLast != NULL ) {
-
- while( MapP != MapLast->NMap ) {
- MapC++;
- MapP = MapP->NMap;
- }
- la[0] = 0;
- la[1] = MapC;
- fwrite(la, 2, 4, fp);
- }
-
- SaveField( &Field, LastField, fp );
- SaveObject( &Object_, LastObject, fp );
- SaveMonster( &Monster, LastMonster, fp );
- SaveText( &Texture, LastText, fp );
- SaveAttrib( &Attribute, LastAttrib, fp );
-
- while( MapFirst != MapLast->NMap && MapFirst != NULL ) {
-
- fwrite(MapFirst->name, 26, 1, fp);
-
- la[0] = MapFirst->x;
- la[1] = MapFirst->y;
- la[2] = MapFirst->z;
-
- fwrite(la, 4, 3, fp);
-
- /* Map save function calls other functions that save data connected under
- the Map. Some other functions do that too. */
-
- if( MapFirst->Poly3 != NULL ) {
- SavePoly3( MapFirst->Poly3, MapFirst->PolyLast3, fp); }
- else {
- la[0] = 1;
- la[1] = 0;
- fwrite(la, 2, 4, fp);
- }
- if( MapFirst->Poly4 != NULL ) {
- SavePoly4( MapFirst->Poly4, MapFirst->PolyLast4, fp); }
- else {
- la[0] = 2;
- la[1] = 0;
- fwrite(la, 2, 4, fp);
- }
- if( MapFirst->MapField != NULL ) {
- SaveMapField( MapFirst->MapField, MapFirst->MapFieldLast, fp ); }
- else {
- la[0] = 6;
- la[1] = 0;
- fwrite(la, 2, 4, fp);
- }
- if( MapFirst->MapObject != NULL ) {
- SaveMapObject( MapFirst->MapObject, MapFirst->MapObjectLast, fp ); }
- else {
- la[0] = 7;
- la[1] = 0;
- fwrite(la, 2, 4, fp);
- }
- if( MapFirst->MapMonster != NULL ) {
- SaveMapMonster( MapFirst->MapMonster, MapFirst->MapMonsterLast, fp ); }
- else {
- la[0] = 8;
- la[1] = 0;
- fwrite(la, 2, 4, fp);
- }
- if( MapFirst->FieldDes != NULL ) {
- SaveFieldDes( MapFirst->FieldDes, MapFirst->FieldDesLast, fp ); }
- else {
- la[0] = 11;
- la[1] = 0;
- fwrite(la, 2, 4, fp);
- }
-
- if( MapFirst->Action != NULL ) {
- SaveAction( MapFirst->Action, MapFirst->ActionLast, fp ); }
- else {
- la[0] = 12;
- la[1] = 0;
- fwrite(la, 2, 4, fp);
- }
-
- MapFirst = MapFirst->NMap;
- }
-
- }
-
- void SaveText(struct Text *TextFirst,struct Text *TextLast,FILE *fp) {
-
- unsigned long int la[3];
-
- unsigned long int TextC = 0;
- struct Text *TextP = TextFirst;
-
- if( TextLast != NULL ) {
-
- while( TextP != TextLast->NText ) {
- TextC++;
- TextP = TextP->NText;
- }
- la[0] = 9;
- la[1] = TextC;
- fwrite(la, 2, 4, fp);
- }
-
- while( TextFirst != TextLast->NText && TextFirst != NULL ) {
-
- fwrite(TextFirst->name, 26, 1, fp);
-
- TextFirst = TextFirst->NText;
- }
-
- }
-
- void SaveAttrib(struct Attrib *AttribFirst,struct Attrib *AttribLast,FILE *fp) {
-
- unsigned long int la[3];
- unsigned long int ia[9];
-
- unsigned long int AttribC = 0;
- struct Attrib *AttribP = AttribFirst;
-
- if( AttribLast != NULL ) {
-
- while( AttribP != NULL ) {
- AttribC++;
- AttribP = AttribP->NAttrib;
- }
- la[0] = 10;
- la[1] = AttribC;
- fwrite(la, 2, 4, fp);
- }
-
- while( AttribFirst != AttribLast->NAttrib && AttribFirst != NULL ) {
-
- ia[0] = AttribFirst->r;
- ia[1] = AttribFirst->g;
- ia[2] = AttribFirst->b;
- ia[3] = AttribFirst->Illumination;
- ia[4] = AttribFirst->Transparency;
- ia[5] = AttribFirst->Reflectivity;
- ia[6] = AttribFirst->Smoothyness;
- ia[7] = AttribFirst->Bumpyness;
- ia[8] = AttribFirst->Effect;
- fwrite(ia, 4, 9, fp);
- fwrite(AttribFirst->name, 26, 1, fp);
-
- AttribFirst = AttribFirst->NAttrib;
- }
-
- }
-
- void SaveFieldDes( struct FieldDes *FDF, struct FieldDes *FDL ,FILE *fp ) {
-
- unsigned long int la[3];
- unsigned long int ia[12];
-
- unsigned long int FieldDesC = 0;
- struct FieldDes *FieldDesP = FDF;
-
- if( FDL != NULL ) {
-
- while( FieldDesP != FDL->NFD ) {
- FieldDesC++;
- FieldDesP = FieldDesP->NFD;
- }
- la[0] = 11;
- la[1] = FieldDesC;
- fwrite(la, 2, 4, fp);
- }
-
- while( FDF != FDL->NFD && FDF != NULL ) {
-
- la[0] = FDF->x;
- la[1] = FDF->y;
- la[2] = FDF->z;
- fwrite(la, 4, 3, fp);
-
- ia[0] = FDF->A;
- ia[1] = FDF->B;
- ia[2] = FDF->C;
- ia[3] = FDF->D;
- ia[4] = FDF->E;
- ia[5] = FDF->F;
- ia[6] = FDF->G;
- ia[7] = FDF->H;
- ia[8] = FDF->I;
- fwrite(ia, 4, 9, fp);
- fwrite(FDF->name, 26, 1, fp);
-
- FDF = FDF->NFD;
- }
-
- }
-
- /* END OF SAVE FUNCTIONS */
-
- Load functions:
-
- void Load( void ) {
-
- struct Library *AslBase;
-
- struct FileRequester *fr;
-
- int cmpres = 0;
-
- FILE *fp;
-
- char File[400];
- char Dir[400];
- char DirFile[400];
- char Smece[] = "Slash^FVR FVMap";
- char Slash[16];
-
- long int la[2];
- struct Map *MapLast;
-
- if (AslBase = OpenLibrary("asl.library", 36L))
- {
- if (fr = (struct FileRequester *)
- AllocAslRequest(ASL_FileRequest, frtags))
- {
- if (AslRequest(fr, 0L)) {
- sprintf( Dir, "%s%s", fr->rf_Dir );
- sprintf( File, "%s%s", fr->rf_File );
- sprintf( DirFile, "%s%s", fr->rf_Dir, fr->rf_File);
- }
- else {
- return;
- }
- }
- FreeAslRequest(fr);
- }
- CloseLibrary(AslBase);
-
- if( strlen( File ) == 0 )
- return;
-
- fp = fopen( DirFile, "rb" );
-
- if( fp == NULL )
- return;
-
- fread( Slash, 16, 1, fp ); /* Read 16 bytes. */
- Slash[15] = 0;
-
- cmpres = strcmp(Slash, Smece); /* Check if it is FVMap save file. */
-
- if( cmpres != 0 ) {
- fclose(fp);
- return;
- }
-
- fread(la, 4, 2, fp); /* Read next data, data description and */
- /* number of members */
-
- MapLast = LoadMap(&Scene, la[1], fp); /* Call function. */
- if( MapLast != NULL ) /* Test if loading has has been made after */
- LastMap = MapLast; /* last member, and if it has, set */
- /* last member to returned one. */
-
- fclose(fp);
-
- ReDrawView(); /* Some internal stuff you don't use :) */
- ReDrawGadgets();
-
- }
-
- /* START OF LOAD FUNCTIONS */
-
- struct Poly3 *LoadPoly3(struct Poly3 *Poly3, unsigned long Poly3C, FILE *fp) {
-
- struct Poly3 *PolyLast3 = NULL;
- struct Poly3 *LastPoly3;
- long int la[11];
-
- LastPoly3 = Poly3->PolyNext3;
-
- for(; Poly3C > 0; Poly3C--) {
-
- fread(la, 4, 11, fp);
-
- Poly3->x1 = la[0];
- Poly3->y1 = la[1];
- Poly3->z1 = la[2];
- Poly3->x2 = la[3];
- Poly3->y2 = la[4];
- Poly3->z2 = la[5];
- Poly3->x3 = la[6];
- Poly3->y3 = la[7];
- Poly3->z3 = la[8];
- Poly3->Texture = &Texture;
- for(; la[9] > 0; la[9]--) {
- if( Poly3->Texture->NText == NULL )
- break;
- Poly3->Texture = Poly3->Texture->NText;
- }
- if( la[9] > 0 )
- Poly3->Texture = &Texture;
- Poly3->Texture->Used++;
-
- Poly3->Attribute = &Attribute;
- for(; la[10] > 0; la[10]--) {
- if( Poly3->Attribute->NAttrib == NULL )
- break;
- Poly3->Attribute = Poly3->Attribute->NAttrib;
- }
- if( la[10] > 0 )
- Poly3->Attribute = &Attribute;
- Poly3->Attribute->Used++;
-
- if( Poly3C > 1 ) {
- Poly3->PolyNext3 = (struct Poly3 *)malloc(sizeof(struct Poly3));
- if( Poly3->PolyNext3 == NULL ) {
- if( LastPoly3 != NULL ) {
- LastPoly3->PolyPrevious3 = Poly3;
- Poly3->PolyNext3 = LastPoly3;
- }
- else {
- Poly3->PolyNext3 = NULL;
- PolyLast3 = Poly3;
- }
- return PolyLast3;
- }
- Poly3->PolyNext3->PolyPrevious3 = Poly3;
- Poly3 = Poly3->PolyNext3;
- }
- else {
- if( LastPoly3 != NULL ) {
- LastPoly3->PolyPrevious3 = Poly3;
- Poly3->PolyNext3 = LastPoly3;
- }
- else {
- Poly3->PolyNext3 = NULL;
- PolyLast3 = Poly3;
- }
- }
- }
-
- return PolyLast3;
-
- }
-
- struct Poly4 *LoadPoly4(struct Poly4 *Poly4, unsigned long Poly4C, FILE *fp) {
-
- struct Poly4 *PolyLast4 = NULL;
- struct Poly4 *LastPoly4;
- long int la[14];
-
- LastPoly4 = Poly4->PolyNext4;
-
- for(; Poly4C > 0; Poly4C--) {
-
- fread(la, 4, 14, fp);
-
- Poly4->x1 = la[0];
- Poly4->y1 = la[1];
- Poly4->z1 = la[2];
- Poly4->x2 = la[3];
- Poly4->y2 = la[4];
- Poly4->z2 = la[5];
- Poly4->x3 = la[6];
- Poly4->y3 = la[7];
- Poly4->z3 = la[8];
- Poly4->x4 = la[9];
- Poly4->y4 = la[10];
- Poly4->z4 = la[11];
- Poly4->Texture = &Texture;
- for(; la[12] > 0; la[12]--) {
- if( Poly4->Texture->NText == NULL )
- break;
- Poly4->Texture = Poly4->Texture->NText;
- }
- if( la[12] > 0 )
- Poly4->Texture = &Texture;
- Poly4->Texture->Used++;
-
- Poly4->Attribute = &Attribute;
- for(; la[13] > 0; la[13]--) {
- if( Poly4->Attribute->NAttrib == NULL )
- break;
- Poly4->Attribute = Poly4->Attribute->NAttrib;
- }
- if( la[13] > 0 )
- Poly4->Attribute = &Attribute;
- Poly4->Attribute->Used++;
-
- if( Poly4C > 1 ) {
- Poly4->PolyNext4 = (struct Poly4 *)malloc(sizeof(struct Poly4));
- if( Poly4->PolyNext4 == NULL ) {
- if( LastPoly4 != NULL ) {
- LastPoly4->PolyPrevious4 = Poly4;
- Poly4->PolyNext4 = LastPoly4;
- }
- else {
- Poly4->PolyNext4 = NULL;
- PolyLast4 = Poly4;
- }
- return PolyLast4;
- }
- Poly4->PolyNext4->PolyPrevious4 = Poly4;
- Poly4 = Poly4->PolyNext4;
- }
- else {
- if( LastPoly4 != NULL ) {
- LastPoly4->PolyPrevious4 = Poly4;
- Poly4->PolyNext4 = LastPoly4;
- }
- else {
- Poly4->PolyNext4 = NULL;
- PolyLast4 = Poly4;
- }
- }
- }
-
- return PolyLast4;
-
- }
-
- struct Action *LoadAction(struct Action *Action, unsigned long ActionC, struct MapObject *MapObject, FILE *fp) {
-
- struct Action *ActionLast = NULL;
- struct Action *LastAction;
- long int la[17];
-
- LastAction = Action->ActionNext;
-
- for(; ActionC > 0; ActionC--) {
-
- fread(la, 4, 7, fp);
-
- Action->x = la[0];
- Action->y = la[1];
- Action->z = la[2];
- if( Action != NULL ) {
- Action->SourceObject = MapObject;
- for(; la[3] > 0; la[3]--) {
- if( Action->SourceObject == NULL )
- break;
- if( Action->SourceObject->NMapObject != NULL )
- Action->SourceObject = Action->SourceObject->NMapObject;
- }
- }
- else
- Action->SourceObject = NULL;
- if( Action->SourceObject != NULL )
- Action->SourceObject->Used++;
-
- if( MapObject != NULL ) {
- Action->DestObject = MapObject;
- for(; la[4] > 0; la[4]--) {
- if( Action->DestObject == NULL )
- break;
- if( Action->DestObject->NMapObject != NULL )
- Action->DestObject = Action->DestObject->NMapObject;
- }
- }
- else
- Action->DestObject = NULL;
- if( Action->DestObject != NULL )
- Action->DestObject->Used++;
-
- Action->ActionValue = la[5];
- Action->ActionValue1 = la[6];
-
- if( ActionC > 1 ) {
- Action->ActionNext = (struct Action *)malloc(sizeof(struct Action));
- if( Action->ActionNext == NULL ) {
- if( LastAction != NULL ) {
- LastAction->ActionPrevious = Action;
- Action->ActionNext = LastAction;
- }
- else {
- Action->ActionNext = NULL;
- ActionLast = Action;
- }
- return ActionLast;
- }
- Action->ActionNext->ActionPrevious = Action;
- Action = Action->ActionNext;
- }
- else {
- if( LastAction != NULL ) {
- LastAction->ActionPrevious = Action;
- Action->ActionNext = LastAction;
- }
- else {
- Action->ActionNext = NULL;
- ActionLast = Action;
- }
- }
- }
-
- return ActionLast;
-
- }
-
- struct Object *LoadObject(struct Object *ObjectI, unsigned long ObjectC, FILE *fp) {
-
- size_t w;
-
- struct Object *ObjectLast = NULL;
- struct Object *LastObject;
- struct Poly3 *PolyLast3;
- struct Poly4 *PolyLast4;
- long int la[3];
-
- LastObject = ObjectI->NObject;
-
- LastObjectNr--;
-
- for(; ObjectC > 0; ObjectC--) {
-
- fread(ObjectI->name, 26, 1, fp);
-
- w = fread(la, 4, 2, fp);
- if( w != 2 )
- break;
- if( la[1] != 0 ) {
- if( ObjectI->Poly3 == NULL ) {
- ObjectI->Poly3 = ObjectI->PolyActive3 = ObjectI->PolyLast3 =
- ( struct Poly3 * )malloc( sizeof( struct Poly3 ) );
- if( ObjectI->Poly3 == NULL ) {
- ObjectI->ActivePoly3Nr = 0;
- goto O1;
- }
- ObjectI->Poly3->PolyNext3 = NULL;
- ObjectI->Poly3->PolyPrevious3 = NULL;
- }
- PolyLast3 = LoadPoly3(ObjectI->PolyActive3, la[1], fp);
- if( PolyLast3 != NULL )
- ObjectI->PolyLast3 = PolyLast3;
- if( ObjectI->ActivePoly3Nr == 0 ) {
- ObjectI->PolyActive3 = ObjectI->Poly3;
- ObjectI->ActivePoly3Nr = 1;
- }
- }
-
- O1: w = fread(la, 4, 2, fp);
- if( w != 2 )
- break;
- if( la[1] != 0 ) {
- if( ObjectI->Poly4 == NULL ) {
- ObjectI->Poly4 = ObjectI->PolyActive4 = ObjectI->PolyLast4 =
- ( struct Poly4 * )malloc( sizeof( struct Poly4 ) );
- if( ObjectI->Poly4 == NULL ) {
- ObjectI->ActivePoly4Nr = 0;
- goto O2;
- }
- ObjectI->Poly4->PolyNext4 = NULL;
- ObjectI->Poly4->PolyPrevious4 = NULL;
- }
- PolyLast4 = LoadPoly4(ObjectI->PolyActive4, la[1], fp);
- if( PolyLast4 != NULL )
- ObjectI->PolyLast4 = PolyLast4;
- if( ObjectI->ActivePoly4Nr == 0 ) {
- ObjectI->PolyActive4 = ObjectI->Poly4;
- ObjectI->ActivePoly4Nr = 1;
- }
- }
-
- O2: if( ObjectC > 1 ) {
- ObjectI->NObject = (struct Object *)malloc(sizeof(struct Object));
- if( ObjectI->NObject == NULL ) {
- if( LastObject != NULL ) {
- LastObject->PObject = ObjectI;
- ObjectI->NObject = LastObject;
- }
- else {
- ObjectI->NObject = NULL;
- ObjectLast = ObjectI;
- }
- return ObjectLast;
- }
- ObjectI->NObject->PObject = ObjectI;
- ObjectI = ObjectI->NObject;
- ObjectI->Object = ObjectC - 1;
- ObjectI->Used = 0;
- ObjectI->Poly3 = NULL;
- ObjectI->Poly4 = NULL;
- ObjectI->PolyActive3 = NULL;
- ObjectI->PolyActive4 = NULL;
- ObjectI->ActivePoly3Nr = 0;
- ObjectI->PolyLast3 = NULL;
- ObjectI->PolyLast4 = NULL;
- ObjectI->ActivePoly4Nr = 0;
- strcpy( ObjectI->name, "" );
- }
- else {
- if( LastObject != NULL ) {
- LastObject->PObject = ObjectI;
- ObjectI->NObject = LastObject;
- }
- else {
- ObjectI->NObject = NULL;
- ObjectLast = ObjectI;
- }
- }
-
- LastObjectNr++;
-
- }
-
- return ObjectLast;
-
- }
-
- struct MapObject *LoadMapObject( struct MapObject *MapObject, unsigned long MapObjectC, FILE *fp) {
-
- struct MapObject *MapObjectLast = NULL;
- struct MapObject *LastMapObject;
- long int la[4];
-
- LastMapObject = MapObject->NMapObject;
-
- for(; MapObjectC > 0; MapObjectC--) {
-
- fread(la, 4, 4, fp);
- MapObject->x = la[0];
- MapObject->y = la[1];
- MapObject->z = la[2];
- MapObject->Object = &Object_;
- for(; la[3] > 0; la[3]--) {
- if( MapObject->Object->NObject == NULL )
- break;
- MapObject->Object = MapObject->Object->NObject;
- }
- if( la[3] > 0 )
- MapObject->Object = &Object_;
- MapObject->Object->Used++;
-
- if( MapObjectC > 1 ) {
- MapObject->NMapObject = (struct MapObject *)malloc(sizeof(struct MapObject));
- if( MapObject->NMapObject == NULL ) {
- if( LastMapObject != NULL ) {
- LastMapObject->PMapObject = MapObject;
- MapObject->NMapObject = LastMapObject;
- }
- else {
- MapObject->NMapObject = NULL;
- MapObjectLast = MapObject;
- }
- return MapObjectLast;
- }
- MapObject->NMapObject->PMapObject = MapObject;
- MapObject = MapObject->NMapObject;
- }
- else {
- if( LastMapObject != NULL ) {
- LastMapObject->PMapObject = MapObject;
- MapObject->NMapObject = LastMapObject;
- }
- else {
- MapObject->NMapObject = NULL;
- MapObjectLast = MapObject;
- }
- }
- }
-
- return MapObjectLast;
-
- }
-
- struct MapField *LoadMapField( struct MapField *MapField, unsigned long MapFieldC, FILE *fp) {
-
- struct MapField *MapFieldLast = NULL;
- struct MapField *LastMapField;
- long int la[4];
-
- LastMapField = MapField->NMapField;
-
- for(; MapFieldC > 0; MapFieldC--) {
-
- fread(la, 4, 4, fp);
- MapField->x = la[0];
- MapField->y = la[1];
- MapField->z = la[2];
- MapField->Field = &Field;
- for(; la[3] > 0; la[3]--) {
- if( MapField->Field->NField == NULL )
- break;
- MapField->Field = MapField->Field->NField;
- }
- if( la[3] > 0 )
- MapField->Field = &Field;
- MapField->Field->Used++;
-
- if( MapFieldC > 1 ) {
- MapField->NMapField = (struct MapField *)malloc(sizeof(struct MapField));
- if( MapField->NMapField == NULL ) {
- if( LastMapField != NULL ) {
- LastMapField->PMapField = MapField;
- MapField->NMapField = LastMapField;
- }
- else {
- MapField->NMapField = NULL;
- MapFieldLast = MapField;
- }
- return MapFieldLast;
- }
- MapField->NMapField->PMapField = MapField;
- MapField = MapField->NMapField;
- }
- else {
- if( LastMapField != NULL ) {
- LastMapField->PMapField = MapField;
- MapField->NMapField = LastMapField;
- }
- else {
- MapField->NMapField = NULL;
- MapFieldLast = MapField;
- }
- }
- }
-
- return MapFieldLast;
-
- }
-
- struct Field *LoadField(struct Field *FieldI, unsigned long FieldC, FILE *fp) {
-
- size_t w;
-
- struct Field *FieldLast = NULL;
- struct Field *LastField;
- struct Poly3 *PolyLast3;
- struct Poly4 *PolyLast4;
- struct MapObject *MapObjectLast;
- long int la[3];
-
- LastField = FieldI->NField;
-
- LastFieldNr--;
-
- for(; FieldC > 0; FieldC--) {
-
- fread(FieldI->name, 26, 1, fp);
-
- w = fread(la, 4, 2, fp);
- if( w != 2 ) {
- FieldI->Poly3 = NULL;
- FieldI->PolyActive3 = NULL;
- FieldI->PolyLast3 = NULL;
- FieldI->ActivePoly3Nr = 0;
- break;
- }
- if( la[1] != 0 ) {
- if( FieldI->Poly3 == NULL ) {
- FieldI->Poly3 = FieldI->PolyActive3 = FieldI->PolyLast3 =
- ( struct Poly3 * )malloc( sizeof( struct Poly3 ) );
- if( FieldI->Poly3 == NULL ) {
- FieldI->ActivePoly3Nr = 0;
- goto F1;
- }
- FieldI->Poly3->PolyNext3 = NULL;
- FieldI->Poly3->PolyPrevious3 = NULL;
- }
- PolyLast3 = LoadPoly3(FieldI->PolyActive3, la[1], fp);
- if( PolyLast3 != NULL )
- FieldI->PolyLast3 = PolyLast3;
- if( FieldI->ActivePoly3Nr == 0 ) {
- FieldI->PolyActive3 = FieldI->Poly3;
- FieldI->ActivePoly3Nr = 1;
- }
- }
-
- F1: w = fread(la, 4, 2, fp);
- if( w != 2 ) {
- FieldI->Poly4 = NULL;
- FieldI->PolyActive4 = NULL;
- FieldI->PolyLast4 = NULL;
- FieldI->ActivePoly4Nr = 0;
- break;
- }
- if( la[1] != 0 ) {
- if( FieldI->Poly4 == NULL ) {
- FieldI->Poly4 = FieldI->PolyActive4 = FieldI->PolyLast4 =
- ( struct Poly4 * )malloc( sizeof( struct Poly4 ) );
- if( FieldI->Poly4 == NULL ) {
- FieldI->ActivePoly4Nr = 0;
- goto F2;
- }
- FieldI->Poly4->PolyNext4 = NULL;
- FieldI->Poly4->PolyPrevious4 = NULL;
- }
- PolyLast4 = LoadPoly4(FieldI->PolyActive4, la[1], fp);
- if( PolyLast4 != NULL )
- FieldI->PolyLast4 = PolyLast4;
- if( FieldI->ActivePoly4Nr == 0 ) {
- FieldI->PolyActive4 = FieldI->Poly4;
- FieldI->ActivePoly4Nr = 1;
- }
- }
-
- F2: w = fread(la, 4, 2, fp);
- if( w != 2 ) {
- FieldI->MapObject = NULL;
- FieldI->MapObjectActive = NULL;
- FieldI->MapObjectLast = NULL;
- FieldI->ActiveMapObjectNr = 0;
- break;
- }
- if( la[1] != 0 ) {
- if( FieldI->MapObject == NULL ) {
- FieldI->MapObject = FieldI->MapObjectActive = FieldI->MapObjectLast =
- ( struct MapObject * )malloc( sizeof( struct MapObject ) );
- if( FieldI->MapObject == NULL ) {
- FieldI->ActiveMapObjectNr = 0;
- goto F3;
- }
- FieldI->MapObject->NMapObject = NULL;
- FieldI->MapObject->PMapObject = NULL;
- }
- MapObjectLast = LoadMapObject(FieldI->MapObjectActive, la[1], fp);
- if( MapObjectLast != NULL )
- FieldI->MapObjectLast = MapObjectLast;
- if( FieldI->ActiveMapObjectNr == 0 ) {
- FieldI->MapObjectActive = FieldI->MapObject;
- FieldI->ActiveMapObjectNr = 1;
- }
- }
-
- F3: if( FieldC > 1 ) {
- FieldI->NField = (struct Field *)malloc(sizeof(struct Field));
- if( FieldI->NField == NULL ) {
- if( LastField != NULL ) {
- LastField->PField = FieldI;
- FieldI->NField = LastField;
- }
- else {
- FieldI->NField = NULL;
- FieldLast = FieldI;
- }
- return FieldLast;
- }
- FieldI->NField->PField = FieldI;
- FieldI = FieldI->NField;
- FieldI->Field = FieldC - 1;
- FieldI->Used = 0;
- FieldI->Poly3 = NULL;
- FieldI->Poly4 = NULL;
- FieldI->PolyActive3 = NULL;
- FieldI->PolyActive4 = NULL;
- FieldI->ActivePoly3Nr = 0;
- FieldI->PolyLast3 = NULL;
- FieldI->PolyLast4 = NULL;
- FieldI->ActivePoly4Nr = 0;
- FieldI->MapObject = NULL;
- strcpy( FieldI->name, "" );
- }
- else {
- if( LastField != NULL ) {
- LastField->PField = FieldI;
- FieldI->NField = LastField;
- }
- else {
- FieldI->NField = NULL;
- FieldLast = FieldI;
- }
- }
-
- LastFieldNr++;
-
- }
-
- return FieldLast;
-
- }
-
- struct Monster *LoadMonster(struct Monster *MonsterI, unsigned long MonsterC, FILE *fp) {
-
- struct Monster *MonsterLast = NULL;
- struct Monster *LastMonster;
-
- LastMonster = MonsterI->NMonster;
-
- LastMonsterNr--;
-
- for(; MonsterC > 0; MonsterC--) {
-
- fread(MonsterI->name, 26, 1, fp);
-
- if( MonsterC > 1 ) {
- MonsterI->NMonster = (struct Monster *)malloc(sizeof(struct Monster));
- if( MonsterI->NMonster == NULL ) {
- if( LastMonster != NULL ) {
- LastMonster->PMonster = MonsterI;
- MonsterI->NMonster = LastMonster;
- }
- else {
- MonsterI->NMonster = NULL;
- MonsterLast = MonsterI;
- }
- return MonsterLast;
- }
- MonsterI->NMonster->PMonster = MonsterI;
- MonsterI = MonsterI->NMonster;
- MonsterI->Monster = MonsterC - 1;
- MonsterI->Used = 0;
- strcpy( MonsterI->name, "" );
- }
- else {
- if( LastMonster != NULL ) {
- LastMonster->PMonster = MonsterI;
- MonsterI->NMonster = LastMonster;
- }
- else {
- MonsterI->NMonster = NULL;
- MonsterLast = MonsterI;
- }
- }
-
- LastMonsterNr++;
-
- }
-
- return MonsterLast;
-
- }
-
- struct MapMonster *LoadMapMonster( struct MapMonster *MapMonster, unsigned long MapMonsterC, FILE *fp) {
-
- struct MapMonster *MapMonsterLast = NULL;
- struct MapMonster *LastMapMonster;
- long int la[4];
-
- LastMapMonster = MapMonster->NMapMonster;
-
- for(; MapMonsterC > 0; MapMonsterC--) {
-
- fread(la, 4, 4, fp);
- MapMonster->x = la[0];
- MapMonster->y = la[1];
- MapMonster->z = la[2];
- MapMonster->Monster = &Monster;
- for(; la[3] > 0; la[3]--) {
- if( MapMonster->Monster->NMonster == NULL )
- break;
- MapMonster->Monster = MapMonster->Monster->NMonster;
- }
- if( la[3] > 0 )
- MapMonster->Monster = &Monster;
- MapMonster->Monster->Used++;
-
- if( MapMonsterC > 1 ) {
- MapMonster->NMapMonster = (struct MapMonster *)malloc(sizeof(struct MapMonster));
- if( MapMonster->NMapMonster == NULL ) {
- if( LastMapMonster != NULL ) {
- LastMapMonster->PMapMonster = MapMonster;
- MapMonster->NMapMonster = LastMapMonster;
- }
- else {
- MapMonster->NMapMonster = NULL;
- MapMonsterLast = MapMonster;
- }
- return MapMonsterLast;
- }
- MapMonster->NMapMonster->PMapMonster = MapMonster;
- MapMonster = MapMonster->NMapMonster;
- }
- else {
- if( LastMapMonster != NULL ) {
- LastMapMonster->PMapMonster = MapMonster;
- MapMonster->NMapMonster = LastMapMonster;
- }
- else {
- MapMonster->NMapMonster = NULL;
- MapMonsterLast = MapMonster;
- }
- }
- }
-
- return MapMonsterLast;
-
- }
-
- struct Text *LoadText(struct Text *TextI, unsigned long TextC, FILE *fp) {
-
- struct Text *TextLast = NULL;
- struct Text *LastText;
-
- LastText = TextI->NText;
-
- LastTextNr--;
-
- for(; TextC > 0; TextC--) {
-
- fread(TextI->name, 26, 1, fp);
-
- if( TextC > 1 ) {
- TextI->NText = (struct Text *)malloc(sizeof(struct Text));
- if( TextI->NText == NULL ) {
- if( LastText != NULL ) {
- LastText->PText = TextI;
- TextI->NText = LastText;
- }
- else {
- TextI->NText = NULL;
- TextLast = TextI;
- }
- return TextLast;
- }
- TextI->NText->PText = TextI;
- TextI = TextI->NText;
- strcpy( TextI->name, "" );
- TextI->Texture = TextC - 1;
- TextI->Used = 0;
- }
- else {
- if( LastText != NULL ) {
- LastText->PText = TextI;
- TextI->NText = LastText;
- }
- else {
- TextI->NText = NULL;
- TextLast = TextI;
- }
- }
-
- LastTextNr++;
-
- }
-
- return TextLast;
-
- }
-
- struct Attrib *LoadAttrib(struct Attrib *AttribI, unsigned long AttribC, FILE *fp) {
-
- size_t w;
-
- struct Attrib *AttribLast = NULL;
- struct Attrib *LastAttrib;
- unsigned long int ia[9];
-
- LastAttrib = AttribI->NAttrib;
-
- LastAttribNr--;
-
- for(; AttribC > 0; AttribC--) {
-
- w = fread(ia, 4, 9, fp);
- if( w != 9 )
- AttribI->r = ia[0];
- AttribI->g = ia[1];
- AttribI->b = ia[2];
- AttribI->Illumination = ia[3];
- AttribI->Transparency = ia[4];
- AttribI->Reflectivity = ia[5];
- AttribI->Smoothyness = ia[6];
- AttribI->Bumpyness = ia[7];
- AttribI->Effect = ia[8];
- fread(AttribI->name, 26, 1, fp);
-
- if( AttribC > 1 ) {
- AttribI->NAttrib = (struct Attrib *)malloc(sizeof(struct Attrib));
- if( AttribI->NAttrib == NULL ) {
- if( LastAttrib != NULL ) {
- LastAttrib->PAttrib = AttribI;
- AttribI->NAttrib = LastAttrib;
- }
- else {
- AttribI->NAttrib = NULL;
- AttribLast = AttribI;
- }
- return AttribLast;
- }
- AttribI->NAttrib->PAttrib = AttribI;
- AttribI = AttribI->NAttrib;
- strcpy( AttribI->name, "" );
- AttribI->Attribute = AttribC - 1;
- AttribI->Used = 0;
- AttribI->r = 0;
- AttribI->g = 0;
- AttribI->b = 0;
- AttribI->Illumination = 0;
- AttribI->Transparency = 0;
- AttribI->Reflectivity = 0;
- AttribI->Smoothyness = 0;
- AttribI->Bumpyness = 0;
- AttribI->Effect = 0;
- }
- else {
- if( LastAttrib != NULL ) {
- LastAttrib->PAttrib = AttribI;
- AttribI->NAttrib = LastAttrib;
- }
- else {
- AttribI->NAttrib = NULL;
- AttribLast = AttribI;
- }
- }
-
- LastAttribNr++;
-
- }
-
- return AttribLast;
-
- }
-
- struct FieldDes *LoadFieldDes(struct FieldDes *FieldDes, unsigned long FieldDesC, FILE *fp) {
-
- struct FieldDes *FieldDesLast = NULL;
- struct FieldDes *LastFieldDes;
- long int la[11];
- unsigned long int ia[9];
-
- LastFieldDes = FieldDes->NFD;
-
- for(; FieldDesC > 0; FieldDesC--) {
-
- fread(la, 4, 3, fp);
-
- FieldDes->x = la[0];
- FieldDes->y = la[1];
- FieldDes->z = la[2];
-
- fread(ia, 4, 9, fp);
- FieldDes->A = ia[0];
- FieldDes->B = ia[1];
- FieldDes->C = ia[2];
- FieldDes->D = ia[3];
- FieldDes->E = ia[4];
- FieldDes->F = ia[5];
- FieldDes->G = ia[6];
- FieldDes->H = ia[7];
- FieldDes->I = ia[8];
- fread(FieldDes->name, 26, 1, fp);
-
- if( FieldDesC > 1 ) {
- FieldDes->NFD = (struct FieldDes *)malloc(sizeof(struct FieldDes));
- if( FieldDes->NFD == NULL ) {
- if( LastFieldDes != NULL ) {
- LastFieldDes->PFD = FieldDes;
- FieldDes->NFD = LastFieldDes;
- }
- else {
- FieldDes->NFD = NULL;
- FieldDesLast = FieldDes;
- }
- return FieldDesLast;
- }
- FieldDes->NFD->PFD = FieldDes;
- FieldDes = FieldDes->NFD;
- }
- else {
- if( LastFieldDes != NULL ) {
- LastFieldDes->PFD = FieldDes;
- FieldDes->NFD = LastFieldDes;
- }
- else {
- FieldDes->NFD = NULL;
- FieldDesLast = FieldDes;
- }
- }
- }
-
- return FieldDesLast;
-
- }
-
- struct Map *LoadMap(struct Map *MapI, unsigned long MapC, FILE *fp) {
-
- size_t w;
-
- struct Map *MapLast = NULL;
- struct Map *LastMap;
- struct Field *FieldLast;
- struct Object *ObjectLast;
- struct Monster *MonsterLast;
- struct Text *TextLast;
- struct Attrib *AttribLast;
- struct MapField *MapFieldLast;
- struct MapObject *MapObjectLast;
- struct MapMonster *MapMonsterLast;
- struct FieldDes *FieldDesLast;
- struct Action *ActionLast;
- struct Poly3 *PolyLast3;
- struct Poly4 *PolyLast4;
- long int la[3];
-
- LastMap = MapI->NMap;
-
- w = fread(la, 4, 2, fp);
- FieldLast = LoadField(&Field, la[1], fp);
- if( FieldLast != NULL )
- LastField = FieldLast;
-
- w = fread(la, 4, 2, fp);
- ObjectLast = LoadObject(&Object_, la[1], fp);
- if( ObjectLast != NULL )
- LastObject = ObjectLast;
-
- w = fread(la, 4, 2, fp);
- MonsterLast = LoadMonster(&Monster, la[1], fp);
- if( MonsterLast != NULL )
- LastMonster = MonsterLast;
-
- w = fread(la, 4, 2, fp);
- TextLast = LoadText(&Texture, la[1], fp);
- if( TextLast != NULL )
- LastText = TextLast;
-
- w = fread(la, 4, 2, fp);
- AttribLast = LoadAttrib(&Attribute, la[1], fp);
- if( AttribLast != NULL )
- LastAttrib = AttribLast;
-
- LastMapNr--;
-
- for(; MapC > 0; MapC--) {
-
- fread(MapI->name, 26, 1, fp);
-
- fread(la, 4, 3, fp);
-
- MapI->x = la[0];
- MapI->y = la[1];
- MapI->z = la[2];
-
- w = fread(la, 4, 2, fp);
- if( w != 2 ) {
- MapI->Poly3 = NULL;
- MapI->PolyActive3 = NULL;
- MapI->PolyLast3 = NULL;
- MapI->ActivePoly3Nr = 0;
- break;
- }
- if( la[1] != 0 ) {
- if( MapI->Poly3 == NULL ) {
- MapI->Poly3 = MapI->PolyActive3 = MapI->PolyLast3 =
- ( struct Poly3 * )malloc( sizeof( struct Poly3 ) );
- if( MapI->Poly3 == NULL ) {
- MapI->ActivePoly3Nr = 0;
- goto M1;
- }
- MapI->Poly3->PolyNext3 = NULL;
- MapI->Poly3->PolyPrevious3 = NULL;
- }
- PolyLast3 = LoadPoly3(MapI->PolyActive3, la[1], fp);
- if( PolyLast3 != NULL )
- MapI->PolyLast3 = PolyLast3;
- if( MapI->ActivePoly3Nr == 0 ) {
- MapI->PolyActive3 = MapI->Poly3;
- MapI->ActivePoly3Nr = 1;
- }
- }
-
- M1: w = fread(la, 4, 2, fp);
- if( w != 2 ) {
- MapI->Poly4 = NULL;
- MapI->PolyActive4 = NULL;
- MapI->PolyLast4 = NULL;
- MapI->ActivePoly4Nr = 0;
- break;
- }
- if( la[1] != 0 ) {
- if( MapI->Poly4 == NULL ) {
- MapI->Poly4 = MapI->PolyActive4 = MapI->PolyLast4 =
- ( struct Poly4 * )malloc( sizeof( struct Poly4 ) );
- if( MapI->Poly4 == NULL ) {
- MapI->ActivePoly4Nr = 0;
- goto M2;
- }
- MapI->Poly4->PolyNext4 = NULL;
- MapI->Poly4->PolyPrevious4 = NULL;
- }
- PolyLast4 = LoadPoly4(MapI->PolyActive4, la[1], fp);
- if( PolyLast4 != NULL )
- MapI->PolyLast4 = PolyLast4;
- if( MapI->ActivePoly4Nr == 0 ) {
- MapI->PolyActive4 = MapI->Poly4;
- MapI->ActivePoly4Nr = 1;
- }
- }
-
- M2: w = fread(la, 4, 2, fp);
- if( w != 2 ) {
- MapI->MapField = NULL;
- MapI->MapFieldActive = NULL;
- MapI->MapFieldLast = NULL;
- MapI->ActiveMapFieldNr = 0;
- break;
- }
- if( la[1] != 0 ) {
- if( MapI->MapField == NULL ) {
- MapI->MapField = MapI->MapFieldActive = MapI->MapFieldLast =
- ( struct MapField * )malloc( sizeof( struct MapField ) );
- if( MapI->MapField == NULL ) {
- MapI->ActiveMapFieldNr = 0;
- goto M3;
- }
- MapI->MapField->NMapField = NULL;
- MapI->MapField->PMapField = NULL;
- }
- MapFieldLast = LoadMapField(MapI->MapFieldActive, la[1], fp);
- if( MapFieldLast != NULL )
- MapI->MapFieldLast = MapFieldLast;
- if( MapI->ActiveMapFieldNr == 0 ) {
- MapI->MapFieldActive = MapI->MapField;
- MapI->ActiveMapFieldNr = 1;
- }
- }
-
- M3: w = fread(la, 4, 2, fp);
- if( w != 2 ) {
- MapI->MapObject = NULL;
- MapI->MapObjectActive = NULL;
- MapI->MapObjectLast = NULL;
- MapI->ActiveMapObjectNr = 0;
- break;
- }
- if( la[1] != 0 ) {
- if( MapI->MapObject == NULL ) {
- MapI->MapObject = MapI->MapObjectActive = MapI->MapObjectLast =
- ( struct MapObject * )malloc( sizeof( struct MapObject ) );
- if( MapI->MapObject == NULL ) {
- MapI->ActiveMapObjectNr = 0;
- goto M4;
- }
- MapI->MapObject->NMapObject = NULL;
- MapI->MapObject->PMapObject = NULL;
- }
- MapObjectLast = LoadMapObject(MapI->MapObjectActive, la[1], fp);
- if( MapObjectLast != NULL )
- MapI->MapObjectLast = MapObjectLast;
- if( MapI->ActiveMapObjectNr == 0 ) {
- MapI->MapObjectActive = MapI->MapObject;
- MapI->ActiveMapObjectNr = 1;
- }
- }
-
- M4: w = fread(la, 4, 2, fp);
- if( w != 2 ) {
- MapI->MapMonster = NULL;
- MapI->MapMonsterActive = NULL;
- MapI->MapMonsterLast = NULL;
- MapI->ActiveMapMonsterNr = 0;
- break;
- }
- if( la[1] != 0 ) {
- if( MapI->MapMonster == NULL ) {
- MapI->MapMonster = MapI->MapMonsterActive = MapI->MapMonsterLast =
- ( struct MapMonster * )malloc( sizeof( struct MapMonster ) );
- if( MapI->MapMonster == NULL ) {
- MapI->ActiveMapMonsterNr = 0;
- goto M5;
- }
- MapI->MapMonster->NMapMonster = NULL;
- MapI->MapMonster->PMapMonster = NULL;
- }
- MapMonsterLast = LoadMapMonster(MapI->MapMonsterActive, la[1], fp);
- if( MapMonsterLast != NULL )
- MapI->MapMonsterLast = MapMonsterLast;
- if( MapI->ActiveMapMonsterNr == 0 ) {
- MapI->MapMonsterActive = MapI->MapMonster;
- MapI->ActiveMapMonsterNr = 1;
- }
- }
-
- M5: w = fread(la, 4, 2, fp);
- if( w != 2 ) {
- MapI->FieldDes = NULL;
- MapI->FieldDesActive = NULL;
- MapI->FieldDesLast = NULL;
- MapI->ActiveFieldDesNr = 0;
- break;
- }
- if( la[1] != 0 ) {
- if( MapI->FieldDes == NULL ) {
- MapI->FieldDes = MapI->FieldDesActive = MapI->FieldDesLast =
- ( struct FieldDes * )malloc( sizeof( struct FieldDes ) );
- if( MapI->FieldDes == NULL ) {
- MapI->ActiveFieldDesNr = 0;
- goto M6;
- }
- MapI->FieldDes->NFD = NULL;
- MapI->FieldDes->PFD = NULL;
- }
- FieldDesLast = LoadFieldDes(MapI->FieldDesActive, la[1], fp);
- if( FieldDesLast != NULL )
- MapI->FieldDesLast = FieldDesLast;
- if( MapI->ActiveFieldDesNr == 0 ) {
- MapI->FieldDesActive = MapI->FieldDes;
- MapI->ActiveFieldDesNr = 1;
- }
- }
-
- M6: w = fread(la, 4, 2, fp);
- if( w != 2 ) {
- MapI->Action = NULL;
- MapI->ActionActive = NULL;
- MapI->ActionLast = NULL;
- MapI->ActiveActionNr = 0;
- break;
- }
- if( la[1] != 0 ) {
- if( MapI->Action == NULL ) {
- MapI->Action = MapI->ActionActive = MapI->ActionLast =
- ( struct Action * )malloc( sizeof( struct Action ) );
- if( MapI->Action == NULL ) {
- MapI->ActiveActionNr = 0;
- goto M7;
- }
- MapI->Action->ActionNext = NULL;
- MapI->Action->ActionPrevious = NULL;
- }
- ActionLast = LoadAction(MapI->ActionActive, la[1], MapI->MapObject, fp);
- if( ActionLast != NULL )
- MapI->ActionLast = ActionLast;
- if( MapI->ActiveActionNr == 0 ) {
- MapI->ActionActive = MapI->Action;
- MapI->ActiveActionNr = 1;
- }
- }
-
- M7: if( MapC > 1 ) {
- MapI->NMap = (struct Map *)malloc(sizeof(struct Map));
- if( MapI->NMap == NULL ) {
- if( LastMap != NULL ) {
- LastMap->PMap = MapI;
- MapI->NMap = LastMap;
- }
- else {
- MapI->NMap = NULL;
- MapLast = MapI;
- }
- return MapLast;
- }
- MapI->NMap->PMap = MapI;
- MapI = MapI->NMap;
- MapI->Poly3 = NULL;
- MapI->Poly4 = NULL;
- MapI->PolyActive3 = NULL;
- MapI->PolyActive4 = NULL;
- MapI->ActivePoly3Nr = 0;
- MapI->PolyLast3 = NULL;
- MapI->PolyLast4 = NULL;
- MapI->ActivePoly4Nr = 0;
- MapI->x = 0;
- MapI->y = 0;
- MapI->z = 0;
- MapI->MapField = NULL;
- MapI->MapObject = NULL;
- MapI->MapMonster = NULL;
- MapI->Action = NULL;
- MapI->FieldDes = NULL;
- MapI->MapFieldActive = NULL;
- MapI->MapFieldLast = NULL;
- MapI->ActiveMapFieldNr = 0;
- MapI->MapObjectActive = NULL;
- MapI->MapObjectLast = NULL;
- MapI->ActiveMapObjectNr = 0;
- MapI->MapMonsterActive = NULL;
- MapI->MapMonsterLast = NULL;
- MapI->ActiveMapMonsterNr = 0;
- MapI->FieldDesActive = NULL;
- MapI->FieldDesLast = NULL;
- MapI->ActiveFieldDesNr = 0;
- MapI->ActionActive = NULL;
- MapI->ActionLast = NULL;
- MapI->ActiveActionNr = 0;
- strcpy( MapI->name, "" );
- }
- else {
- if( LastMap != NULL ) {
- LastMap->PMap = MapI;
- MapI->NMap = LastMap;
- }
- else {
- MapI->NMap = NULL;
- MapLast = MapI;
- }
- }
-
- LastMapNr++;
-
- }
-
- return MapLast;
-
- }
-
- /* END OF LOAD FUNCTIONS */
-
- --
-
- Version information:
-
- This is version 1.01 of Fictive Map Maker by Valentin 'Slash' Asler / FVR.
- Some functions are not yet finished and will proboably soon be added and
- others enhanced.
-